package com.ruoyi.web.controller.inspection;

import java.util.List;

import com.ruoyi.inspection.domain.FzInspectionSignIn;
import com.ruoyi.inspection.service.IFzInspectionSignInService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 巡检签到Controller
 * 
 * @author ruoyi
 * @date 2020-03-13
 */
@Controller
@RequestMapping("/inspection/in")
public class FzInspectionSignInController extends BaseController
{
    private String prefix = "inspection/in";

    @Autowired
    private IFzInspectionSignInService fzInspectionSignInService;

    @RequiresPermissions("inspection:in:view")
    @GetMapping()
    public String in()
    {
        return prefix + "/in";
    }

    /**
     * 查询巡检签到列表
     */
    @RequiresPermissions("inspection:in:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(FzInspectionSignIn fzInspectionSignIn)
    {
        startPage();
        List<FzInspectionSignIn> list = fzInspectionSignInService.selectFzInspectionSignInList(fzInspectionSignIn);
        return getDataTable(list);
    }

    /**
     * 导出巡检签到列表
     */
    @RequiresPermissions("inspection:in:export")
    @Log(title = "巡检签到", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(FzInspectionSignIn fzInspectionSignIn)
    {
        List<FzInspectionSignIn> list = fzInspectionSignInService.selectFzInspectionSignInList(fzInspectionSignIn);
        ExcelUtil<FzInspectionSignIn> util = new ExcelUtil<FzInspectionSignIn>(FzInspectionSignIn.class);
        return util.exportExcel(list, "in");
    }

    /**
     * 新增巡检签到
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存巡检签到
     */
    @RequiresPermissions("inspection:in:add")
    @Log(title = "巡检签到", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(FzInspectionSignIn fzInspectionSignIn)
    {
        return toAjax(fzInspectionSignInService.insertFzInspectionSignIn(fzInspectionSignIn));
    }

    /**
     * 修改巡检签到
     */
    @GetMapping("/edit/{signInId}")
    public String edit(@PathVariable("signInId") String signInId, ModelMap mmap)
    {
        FzInspectionSignIn fzInspectionSignIn = fzInspectionSignInService.selectFzInspectionSignInById(signInId);
        mmap.put("fzInspectionSignIn", fzInspectionSignIn);
        return prefix + "/edit";
    }

    /**
     * 修改保存巡检签到
     */
    @RequiresPermissions("inspection:in:edit")
    @Log(title = "巡检签到", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(FzInspectionSignIn fzInspectionSignIn)
    {
        return toAjax(fzInspectionSignInService.updateFzInspectionSignIn(fzInspectionSignIn));
    }

    /**
     * 删除巡检签到
     */
    @RequiresPermissions("inspection:in:remove")
    @Log(title = "巡检签到", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(fzInspectionSignInService.deleteFzInspectionSignInByIds(ids));
    }
}
